<?php

class HomeController extends BaseController {

	/*
	|--------------------------------------------------------------------------
	| Default Home Controller
	|--------------------------------------------------------------------------
	|
	| You may wish to use controllers instead of, or in addition to, Closure
	| based routes. That's great! Here is an example controller method to
	| get you started. To route to this controller, just add the route:
	|
	|	Route::get('/', 'HomeController@showWelcome');
	|
	*/

	public function showWelcome()
	{
		return View::make('hello');
	}
	//demo
	public function login()
	{
		$username = Input::get('username');
		$password = Input::get('password');
		$check_login = User::check_login($username,$password);
		if($check_login==2){
			$data["error_login"] = " The Username or Password is incorrect";
			return View::make("login",$data);
		}
		else{
			Session::put("logined","true");
			Session::put("username",$username);
			Session::put("role",$check_login);
			if($check_login==0)
				return Redirect::to("admin/home");
			else
				return Redirect::to("user/home");
		}
	}

}
